package com.huaguoguo.cyg.webmagic;

import lombok.Data;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.downloader.HttpClientDownloader;
import us.codecraft.webmagic.model.ConsolePageModelPipeline;
import us.codecraft.webmagic.model.OOSpider;
import us.codecraft.webmagic.model.annotation.ExtractBy;
import us.codecraft.webmagic.model.annotation.TargetUrl;
import us.codecraft.webmagic.proxy.Proxy;
import us.codecraft.webmagic.proxy.SimpleProxyProvider;

import java.util.List;

/**
 * 类说明： <br/>
 * author:huaguoguo
 * Date: 2019/8/14
 * Time: 23:45
 */
@Data
@TargetUrl("http://139.9.77.29:8080")
public class MyPageProcessor {

    @ExtractBy("hello")
    private String hello;


    public static void main(String[] args) {
        HttpClientDownloader httpClientDownloader = new HttpClientDownloader();
        httpClientDownloader.setProxyProvider(SimpleProxyProvider.from(new Proxy("219.159.38.208",56210)));
        OOSpider.create(
                Site.me(),
                new ConsolePageModelPipeline(), MyPageProcessor.class)
                .setDownloader(httpClientDownloader)
                .addUrl("http://139.9.77.29:8080/hello")
                .run();
    }
}
